package com.hardydou.common.result;

import cn.hutool.core.util.StrUtil;

/**
 * @author ：hardy
 * @description：不满足继续执行业务的条件异常
 * @date ：Created in 2020/6/29
 * @Copyright ：Hardydou.com
 */
public class NoConditionException extends RuntimeException {

    /***
     * 不满足原因码
     */
    private Code code;
    private static String msgTmpl = "Code: {}({}) retry: {} ";

    /**
     * Constructs a new runtime exception with {@code null} as its
     * detail message.  The cause is not initialized, and may subsequently be
     * initialized by a call to {@link #initCause}.
     */
    public NoConditionException(Code code) {
        super(StrUtil.format(msgTmpl, code.getCode(), code.getTip(), code.isRetry()));
        this.code = code;
    }

    public Code getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }
}
